package com.wuzheng.job.demo.annotation;

import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.dataflow.DataflowJob;
import com.wuzheng.elasticjob.annotation.ElasticJobConf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ArrayList;
import java.util.List;

@ElasticJobConf(name = "demoDataFlowJob", cron = "0/10 * * * * ?", shardingTotalCount = 1)
public class DemoDataFlowJob implements DataflowJob<String> {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public List<String> fetchData(ShardingContext shardingContext) {
        logger.info("fetchData execute-------------");
        List<String> jobList = new ArrayList<>();
        for(int i=0; i<10; i++) {
            jobList.add("job"+i);
        }
        return jobList;
    }

    @Override
    public void processData(ShardingContext shardingContext, List<String> data) {
        logger.info("processData execute------------");
    }
}